* mimic std::optional for flagged Waypoint fields.
* manual adjustments to waypt access usage.
* split optional Waypoint flags, tune packing.
* bring op_flags into Waypoint.
* add comments about future Waypoint optional fields.
* sort Waypoint class almost normally.
private members refered to with decltype need to be defined
before they are referred to.
* remove extra parens around *has_value().
* remove extra parens around *value_or().
* remove more extra parens.
wp_flags() :
shortname_is_synthetic(0),
fmt_use(0),
- temperature(0),
- proximity(0),
- course(0),
- speed(0),
- geoidheight(0),
- depth(0),
is_split(0),
new_trkseg(0) {}
unsigned int shortname_is_synthetic:1;
unsigned int fmt_use:2; /* lightweight "extra data" */
- /* "flagged fields" */
- unsigned int temperature:1; /* temperature field is set */
- unsigned int proximity:1; /* proximity field is set */
- unsigned int course:1; /* course field is set */
- unsigned int speed:1; /* speed field is set */
- unsigned int geoidheight:1; /* geoidheight field is set */
- unsigned int depth:1; /* depth field is set */
- /* !ToDo!
- unsigned int altitude:1; /+ altitude field is set +/
- ... and others
- */
unsigned int is_split:1; /* the waypoint represents a split */
unsigned int new_trkseg:1; /* True if first in new trkseg. */
-
};
// These are dicey as they're collected on read. Subsequent filters may change
double min_alt; /* -unknown_alt => invalid */
};
-#define WAYPT_SET(wpt,member,val) do { (wpt)->member = (val); (wpt)->wpt_flags.member = 1; } while (0)
-#define WAYPT_GET(wpt,member,def) (((wpt)->wpt_flags.member) ? ((wpt)->member) : (def))
-#define WAYPT_UNSET(wpt,member) wpt->wpt_flags.member = 0
-#define WAYPT_HAS(wpt,member) ((wpt)->wpt_flags.member)
-#define WAYPT_EQUAL(wpta,wptb,member) (((wpta)->wpt_flags.member && (wptb)->wpt_flags.member && \
- ((wpta)->member == (wptb)->member)) || \
- (!(wpta)->wpt_flags.member && !(wptb)->wpt_flags.member))
-
/*
* This is a waypoint, as stored in the GPSR. It tries to not
* cater to any specific model or protocol. Anything that needs to
class Waypoint
{
private:
- static Geocache empty_gc_data;
-public:
+ /* Types */
+
+ class op_flags
+ {
+ public:
+ op_flags() :
+ temperature(false),
+ proximity(false),
+ course(false),
+ speed(false),
+ geoidheight(false),
+ depth(false) {}
+ bool temperature:1; /* temperature field is set */
+ bool proximity:1; /* proximity field is set */
+ bool course:1; /* course field is set */
+ bool speed:1; /* speed field is set */
+ bool geoidheight:1; /* geoidheight field is set */
+ bool depth:1; /* depth field is set */
+ /* !ToDo!
+ unsigned int altitude:1; /+ altitude field is set +/
+ ... and hdop,pdop,vdop,fix,sat,heartrate,cadence,power,
+ odometer_distance
+ */
+ };
+
+ /* Data Members */
+
+ static Geocache empty_gc_data;
- double latitude; /* Degrees */
- double longitude; /* Degrees */
- double altitude; /* Meters. */
double geoidheight; /* Height (in meters) of geoid (mean sea level) above WGS84 earth ellipsoid. */
/*
* The units are meters.
*/
double proximity;
+ float course; /* Optional: degrees true */
+ float speed; /* Optional: meters per second. */
+ float temperature; /* Degrees celsius */
+ op_flags opt_flags;
+
+public:
+
+ /* Special Member Functions */
+
+ Waypoint();
+ ~Waypoint();
+ Waypoint(const Waypoint& other);
+ Waypoint& operator=(const Waypoint& other);
+
+ /* Member Functions */
+
+ bool HasUrlLink() const;
+ const UrlLink& GetUrlLink() const;
+ void AddUrlLink(const UrlLink& l);
+ QString CreationTimeXML() const;
+ gpsbabel::DateTime GetCreationTime() const;
+ void SetCreationTime(const gpsbabel::DateTime& t);
+ void SetCreationTime(qint64 t, qint64 ms = 0);
+ Geocache* AllocGCData();
+ int EmptyGCData() const;
+
+// mimic std::optional interface, but use our more space
+// efficient wp_flags.
+#define GEN_WAYPT_METHODS(field) \
+ bool field##_has_value() const \
+ { \
+ return opt_flags.field; \
+ } \
+ decltype(field) field##_value() const \
+ { \
+ if (!opt_flags.field) { \
+ throw std::bad_optional_access(); \
+ } \
+ return field; \
+ } \
+ bool field##s_equal(const Waypoint& other) const \
+ { \
+ return (opt_flags.field && other.opt_flags.field && (field == other.field)) || \
+ (!opt_flags.field && !other.opt_flags.field); \
+ } \
+ decltype(field) field##_value_or(decltype(field) p) const \
+ { \
+ return (opt_flags.field)? field : p; \
+ } \
+ void set_##field(decltype(field) p) \
+ { \
+ field = p; \
+ opt_flags.field = 1; \
+ } \
+ void reset_##field() \
+ { \
+ opt_flags.field = 0; \
+ }
+
+ GEN_WAYPT_METHODS(temperature)
+ GEN_WAYPT_METHODS(proximity)
+ GEN_WAYPT_METHODS(course)
+ GEN_WAYPT_METHODS(speed)
+ GEN_WAYPT_METHODS(geoidheight)
+ GEN_WAYPT_METHODS(depth)
+
+#undef GEN_WAYPT_METHODS
+
+ /* Data Members */
+
+ double latitude; /* Degrees */
+ double longitude; /* Degrees */
+ double altitude; /* Meters. */
/* shortname is a waypoint name as stored in receiver. It should
* strive to be, well, short, and unique. Enforcing length and
UrlList urls;
- wp_flags wpt_flags;
QString icon_descr;
gpsbabel::DateTime creation_time;
+ wp_flags wpt_flags;
/*
* route priority is for use by the simplify filter. If we have
* some reason to believe that the route point is more important,
float hdop;
float vdop;
float pdop;
- float course; /* Optional: degrees true */
- float speed; /* Optional: meters per second. */
fix_type fix; /* Optional: 3d, 2d, etc. */
int sat; /* Optional: number of sats used for fix */
unsigned char heartrate; /* Beats/min. likely to get moved to fs. */
unsigned char cadence; /* revolutions per minute */
float power; /* watts, as measured by cyclists */
- float temperature; /* Degrees celsius */
float odometer_distance; /* Meters */
Geocache* gc_data;
FormatSpecificDataList fs;
const session_t* session; /* pointer to a session struct */
void* extra_data; /* Extra data added by, say, a filter. */
-
-public:
- Waypoint();
- ~Waypoint();
- Waypoint(const Waypoint& other);
- Waypoint& operator=(const Waypoint& other);
-
- bool HasUrlLink() const;
- const UrlLink& GetUrlLink() const;
- void AddUrlLink(const UrlLink& l);
- QString CreationTimeXML() const;
- gpsbabel::DateTime GetCreationTime() const;
- void SetCreationTime(const gpsbabel::DateTime& t);
- void SetCreationTime(qint64 t, qint64 ms = 0);
- Geocache* AllocGCData();
- int EmptyGCData() const;
};
using waypt_cb = void (*)(const Waypoint*);
* with a scaling factor of 100, in km/h.
* The waypoint struct wants the speed as a
* floating-point number, in m/s. */
- WAYPT_SET(wpt, speed, KPH_TO_MPS(be_read32(data + i + 16) / 100.0));
+ wpt->set_speed(KPH_TO_MPS(be_read32(data + i + 16) / 100.0));
}
if (style >= 2) {
speed_ref = tag->data.at(0).toByteArray().at(0);
break;
case GPS_IFD_TAG_SPEED:
- WAYPT_SET(wpt, speed, exif_read_double(tag, 0));
+ wpt->set_speed(exif_read_double(tag, 0));
break;
case GPS_IFD_TAG_DATUM:
datum = exif_read_str(tag);
}
}
- if WAYPT_HAS(wpt, speed) {
+ if (wpt->speed_has_value()) {
switch (speed_ref) {
case 'K':
- wpt->speed = KPH_TO_MPS(wpt->speed);
+ wpt->set_speed(KPH_TO_MPS(wpt->speed_value()));
break;
case 'M':
- wpt->speed = MPH_TO_MPS(wpt->speed);
+ wpt->set_speed(MPH_TO_MPS(wpt->speed_value()));
break;
case 'N':
- wpt->speed = KNOTS_TO_MPS(wpt->speed);
+ wpt->set_speed(KNOTS_TO_MPS(wpt->speed_value()));
break;
default:
- wpt->speed = 0;
- WAYPT_UNSET(wpt, speed);
+ wpt->reset_speed();
warning(MYNAME ": Unknown GPSSpeedRef unit %c (0x%02x)!\n", speed_ref, speed_ref);
}
if (global_opts.debug_level >= 3) {
- if WAYPT_HAS(wpt, speed) {
- printf(MYNAME "-GPSSpeed = %12.2f m/s\n", wpt->speed);
+ if (wpt->speed_has_value()) {
+ printf(MYNAME "-GPSSpeed = %12.2f m/s\n", wpt->speed_value());
}
}
}
exif_remove_tag(GPS_IFD, GPS_IFD_TAG_DOP);
}
- if WAYPT_HAS(wpt, speed) {
+ if (wpt->speed_has_value()) {
exif_put_str(GPS_IFD, GPS_IFD_TAG_SPEEDREF, "K");
- exif_put_double(GPS_IFD, GPS_IFD_TAG_SPEED, 0, MPS_TO_KPH(wpt->speed));
+ exif_put_double(GPS_IFD, GPS_IFD_TAG_SPEED, 0, MPS_TO_KPH(wpt->speed_value()));
} else {
exif_remove_tag(GPS_IFD, GPS_IFD_TAG_SPEEDREF);
exif_remove_tag(GPS_IFD, GPS_IFD_TAG_SPEED);
next_is_new_trkseg = 0;
if (array[i]->dpth < 1.0e25f) {
- WAYPT_SET(wpt, depth, array[i]->dpth);
+ wpt->set_depth(array[i]->dpth);
}
if (array[i]->temperature_populated) {
- WAYPT_SET(wpt, temperature, array[i]->temperature);
+ wpt->set_temperature(array[i]->temperature);
}
track_add_wpt(trk_head, wpt);
wpt->latitude = pvt->lat;
wpt->longitude = pvt->lon;
- WAYPT_SET(wpt, course, 180 + DEG(std::atan2(-pvt->east, -pvt->north)));
+ wpt->set_course(180 + DEG(std::atan2(-pvt->east, -pvt->north)));
/* velocity in m/s */
- WAYPT_SET(wpt,speed, std::sqrt(pvt->north*pvt->north + pvt->east*pvt->east));
+ wpt->set_speed(std::sqrt(pvt->north*pvt->north + pvt->east*pvt->east));
// wpt->vs = pvt->up;
/*
garmin_fs_t::set_category(gmsd, way->category);
}
if (way->dst < 1.0e25f) {
- WAYPT_SET(wpt, proximity, way->dst);
+ wpt->set_proximity(way->dst);
}
if (way->temperature_populated) {
- WAYPT_SET(wpt, temperature, way->temperature);
+ wpt->set_temperature(way->temperature);
}
if (way->dpth < 1.0e25f) {
- WAYPT_SET(wpt, depth, way->dpth);
+ wpt->set_depth(way->dpth);
}
/* will copy until a null character or the end of the fixed length way field is reached, whichever comes first. */
garmin_fs_t::set_cc(gmsd, str_to_unicode(QByteArray(way->cc, qstrnlen(way->cc, sizeof(way->cc)))));
way->dspl = gt_switch_display_mode_value(
garmin_fs_t::get_display(gmsd, way->dspl), gps_waypt_type, 0);
way->category = garmin_fs_t::get_category(gmsd, way->category);
- way->dpth = WAYPT_GET(wpt, depth, way->dpth);
- way->dst = WAYPT_GET(wpt, proximity, way->dpth);
- way->temperature = WAYPT_GET(wpt, temperature, way->temperature);
+ if (wpt->depth_has_value()) {
+ way->dpth = wpt->depth_value();
+ }
+ if (wpt->proximity_has_value()) {
+ way->dst = wpt->proximity_value();
+ }
+ if (wpt->temperature_has_value()) {
+ way->temperature = wpt->temperature_value();
+ }
/* destination may not be null terminated, but we will fill with nulls if necessary */
strncpy(way->cc, str_from_unicode(garmin_fs_t::get_cc(gmsd, nullptr)).constData(), sizeof(way->cc));
}
waypt->SetCreationTime(GPS_Math_Gtime_To_Utime(timestamp));
if (speed != 0xffff) {
- WAYPT_SET(waypt, speed, speed / 1000.0f);
+ waypt->set_speed(speed / 1000.0f);
}
if (heartrate != 0xff) {
waypt->heartrate = heartrate;
waypt->power = power;
}
if (temperature != 0x7f) {
- WAYPT_SET(waypt, temperature, temperature);
+ waypt->set_temperature(temperature);
}
if (new_trkseg) {
waypt->wpt_flags.new_trkseg = 1;
: lat(wpt.latitude),
lon(wpt.longitude),
altitude(wpt.altitude),
- speed(WAYPT_GET(&wpt, speed, -1)),
+ speed(wpt.speed_value_or(-1)),
odometer_distance(wpt.odometer_distance),
creation_time(wpt.creation_time),
shortname(wpt.shortname),
if (!addr.isEmpty() || !phone.isEmpty() ||
(gmsd->flags.category && gmsd->category) ||
- WAYPT_HAS(waypt, depth) ||
- WAYPT_HAS(waypt, proximity) ||
- WAYPT_HAS(waypt, temperature) ||
+ waypt->depth_has_value() ||
+ waypt->proximity_has_value() ||
+ waypt->temperature_has_value() ||
gmsd->flags.display) {
writer->writeStartElement(QStringLiteral("extensions"));
writer->writeStartElement(QStringLiteral("gpxx:WaypointExtension"));
writer->writeNamespace(QStringLiteral("http://www.garmin.com/xmlschemas/GpxExtensions/v3"),
"gpxx");
- if WAYPT_HAS(waypt, proximity) {
- writer->writeTextElement(QStringLiteral("gpxx:Proximity"), QString::number(waypt->proximity, 'f', 6));
+ if (waypt->proximity_has_value()) {
+ writer->writeTextElement(QStringLiteral("gpxx:Proximity"), QString::number(waypt->proximity_value(), 'f', 6));
}
- if WAYPT_HAS(waypt, temperature) {
- writer->writeTextElement(QStringLiteral("gpxx:Temperature"), QString::number(waypt->temperature, 'f', 6));
+ if (waypt->temperature_has_value()) {
+ writer->writeTextElement(QStringLiteral("gpxx:Temperature"), QString::number(waypt->temperature_value(), 'f', 6));
}
- if WAYPT_HAS(waypt, depth) {
- writer->writeTextElement(QStringLiteral("gpxx:Depth"), QString::number(waypt->depth, 'f', 6));
+ if (waypt->depth_has_value()) {
+ writer->writeTextElement(QStringLiteral("gpxx:Depth"), QString::number(waypt->depth_value(), 'f', 6));
}
if (gmsd->flags.display) {
const char* cx;
switch (tag) {
case 1:
if (*cdatastr) {
- WAYPT_SET(waypt, proximity, strtod(cdatastr, nullptr));
+ waypt->set_proximity(strtod(cdatastr, nullptr));
}
break;
case 2:
if (*cdatastr) {
- WAYPT_SET(waypt, temperature, strtod(cdatastr, nullptr));
+ waypt->set_temperature(strtod(cdatastr, nullptr));
}
break;
case 3:
if (*cdatastr) {
- WAYPT_SET(waypt, depth, strtod(cdatastr, nullptr));
+ waypt->set_depth(strtod(cdatastr, nullptr));
}
break;
case 4:
speed = (double)gbfgetint16(fin) / 100; /* speed in meters per second */
if (dist > 0) {
- WAYPT_SET(wpt, proximity, dist);
+ wpt->set_proximity(dist);
}
if (speed > 0) {
/* speed isn't part of a normal waypoint
- WAYPT_SET(wpt, speed, speed);
+ wpt->set_speed(speed);
*/
if ((wpt->shortname.isEmpty() || ((wpt->shortname).indexOf('@'))==-1)) {
if (units == 's') {
double speed = 0;
parse_speed(wpt->shortname.mid(pidx + 1), &speed, scale, MYNAME);
if (speed > 0) {
- WAYPT_SET(wpt, speed, speed);
+ wpt->set_speed(speed);
}
#if 0
wpt->shortname.truncate(pidx);
#endif
- } else if ((opt_speed) && (! WAYPT_HAS(wpt, speed))) {
- WAYPT_SET(wpt, speed, defspeed);
+ } else if ((opt_speed) && (!wpt->speed_has_value())) {
+ wpt->set_speed(defspeed);
}
- if ((opt_proximity) && (! WAYPT_HAS(wpt, proximity))) {
- WAYPT_SET(wpt, proximity, defproximity);
+ if ((opt_proximity) && (!wpt->proximity_has_value())) {
+ wpt->set_proximity(defproximity);
}
- if ((WAYPT_HAS(wpt, speed) && (wpt->speed > 0)) ||
- (WAYPT_HAS(wpt, proximity) && (wpt->proximity > 0))) {
+ if ((wpt->speed_has_value() && (wpt->speed_value() > 0)) ||
+ (wpt->proximity_has_value() && (wpt->proximity_value() > 0))) {
data->alert = 1;
dt->alerts++;
res += 20; /* tag(3) */
gbfputint32(3, fout); /* tag(3) */
gbfputint32(12, fout); /* always 12 */
- if (WAYPT_HAS(wpt, proximity) && (wpt->proximity > 0)) {
- gbfputint16((int) wpt->proximity, fout);
+ if (wpt->proximity_has_value() && (wpt->proximity_value() > 0)) {
+ gbfputint16((int) wpt->proximity_value(), fout);
flag = 4;
} else {
gbfputint16(0, fout);
}
- if (WAYPT_HAS(wpt, speed) && (wpt->speed > 0)) {
- gbfputint16((int)(wpt->speed * 100), fout);
+ if (wpt->speed_has_value() && (wpt->speed_value() > 0)) {
+ gbfputint16((int)(wpt->speed_value() * 100), fout);
flag = 5;
} else {
gbfputint16(0, fout);
}
*fout << "\t";
- double x = WAYPT_GET(wpt, depth, unknown_alt);
+ double x = wpt->depth_value_or(unknown_alt);
if (x != unknown_alt) {
print_distance(x, 1, 0, 1);
}
*fout << "\t";
- x = WAYPT_GET(wpt, proximity, unknown_alt);
+ x = wpt->proximity_value_or(unknown_alt);
if (x != unknown_alt) {
print_distance(x, 0, 0, 0);
}
*fout << "\t";
- x = WAYPT_GET(wpt, temperature, -999);
+ x = wpt->temperature_value_or(-999);
if (x != -999) {
print_temperature(x);
}
}
*fout << "\t";
- double depth = WAYPT_GET(wpt, depth, unknown_alt);
+ double depth = wpt->depth_value_or(unknown_alt);
if (depth != unknown_alt) {
print_distance(depth, 1, 0, 1);
}
if (prev != nullptr) {
*fout << "\t";
delta = wpt->GetCreationTime().toTime_t() - prev->GetCreationTime().toTime_t();
- float temp = WAYPT_GET(wpt, temperature, -999);
+ float temp = wpt->temperature_value_or(-999);
if (temp != -999) {
print_temperature(temp);
}
break;
case 6:
if (parse_distance(str, &d, 1, MYNAME)) {
- WAYPT_SET(wpt, depth, d);
+ wpt->set_depth(d);
}
break;
case 7:
if (parse_distance(str, &d, 1, MYNAME)) {
- WAYPT_SET(wpt, proximity, d);
+ wpt->set_proximity(d);
}
break;
case 8:
if (parse_temperature(str, &d)) {
- WAYPT_SET(wpt, temperature, d);
+ wpt->set_temperature(d);
}
break;
case 9:
break;
case 4:
if (parse_distance(str, &x, 1, MYNAME)) {
- WAYPT_SET(wpt, depth, x);
+ wpt->set_depth(x);
}
break;
case 5:
if (parse_temperature(str, &x)) {
- WAYPT_SET(wpt, temperature, x);
+ wpt->set_temperature(x);
}
break;
case 8:
if (parse_speed(str, &x, 1, MYNAME)) {
- WAYPT_SET(wpt, speed, x);
+ wpt->set_speed(x);
}
break;
case 9:
- WAYPT_SET(wpt, course, xstrtoi(CSTR(str), nullptr, 10));
+ wpt->set_course(xstrtoi(CSTR(str), nullptr, 10));
break;
}
}
qPrintable(QString(res->notes).replace("\r\n", ", ")));
#endif
if (FREAD_C == 1) {
- WAYPT_SET(res, proximity, FREAD_DBL);
+ res->set_proximity(FREAD_DBL);
#if GDB_DEBUG
DBG(GDB_DBG_WPTe, 1)
printf(MYNAME "-wpt \"%s\" (%d): Proximity = %.1f\n",
FREAD(buf, 1);
if (FREAD_C == 1) {
- WAYPT_SET(res, depth, FREAD_DBL);
+ res->set_depth(FREAD_DBL);
#if GDB_DEBUG
DBG(GDB_DBG_WPTe, 1)
printf(MYNAME "-wpt \"%s\" (%d): Depth = %.1f\n",
#endif
if (FREAD_C == 1) {
- WAYPT_SET(res, temperature, FREAD_DBL);
+ res->set_temperature(FREAD_DBL);
#if GDB_DEBUG
DBG(GDB_DBG_WPTe, 1)
printf(MYNAME "-wpt \"%s\" (%d): temperature = %.1f\n",
wpt->SetCreationTime(FREAD_i32);
}
if (FREAD_C == 1) {
- WAYPT_SET(wpt, depth, FREAD_DBL);
+ wpt->set_depth(FREAD_DBL);
}
if (FREAD_C == 1) {
- WAYPT_SET(wpt, temperature, FREAD_DBL);
+ wpt->set_temperature(FREAD_DBL);
}
track_add_wpt(res, wpt);
} else {
FWRITE_CSTR(wpt->description);
}
- FWRITE_DBL(WAYPT_GET(wpt, proximity, unknown_alt), unknown_alt); /* proximity */
+ FWRITE_DBL(wpt->proximity_value_or(unknown_alt), unknown_alt); /* proximity */
FWRITE_i32(display); /* display */
FWRITE_i32(0); /* color */
FWRITE_i32(icon); /* icon */
FWRITE_CSTR(garmin_fs_t::get_state(gmsd, "")); /* state */
FWRITE_CSTR(garmin_fs_t::get_facility(gmsd, "")); /* facility */
FWRITE_C(0); /* unknown */
- FWRITE_DBL(WAYPT_GET(wpt, depth, unknown_alt), unknown_alt); /* depth */
+ FWRITE_DBL(wpt->depth_value_or(unknown_alt), unknown_alt); /* depth */
/* VERSION DEPENDENT CODE */
if (gdb_ver <= GDB_VER_2) {
}
FWRITE_i16(garmin_fs_t::get_category(gmsd, gdb_category));
- FWRITE_DBL(WAYPT_GET(wpt, temperature, 0), 0);
+ FWRITE_DBL(wpt->temperature_value_or(0), 0);
FWRITE_TIME(wpt->GetCreationTime().toTime_t());
/* VERSION DEPENDENT CODE */
FWRITE_LATLON(wpt->longitude);
FWRITE_DBL(wpt->altitude, unknown_alt);
FWRITE_TIME(wpt->GetCreationTime().toTime_t());
- double d = WAYPT_GET(wpt, depth, unknown_alt);
+ double d = wpt->depth_value_or(unknown_alt);
FWRITE_DBL(d, unknown_alt);
- d = WAYPT_GET(wpt, temperature, -99999);
+ d = wpt->temperature_value_or(-99999);
FWRITE_DBL(d, -99999);
}
wpt->longitude = ((int32_t) point.Longitude) / 1000000.0;
wpt->latitude = ((int32_t) point.Latitude) / 1000000.0;
wpt->altitude = point.Altitude;
- WAYPT_SET(wpt, speed, ((double) point.Speed / 100.0) * 1000.0 / 3600.0);
+ wpt->set_speed(((double) point.Speed / 100.0) * 1000.0 / 3600.0);
wpt->heartrate = point.HeartRate;
wpt->cadence = point.Cadence; //TODO convert in any way??
wpt->power = point.Power; //TODO convert in any way??
{
char obuf[1024];
- if WAYPT_HAS(wpt, speed) {
- gpssim_write_spd(MPS_TO_KNOTS(wpt->speed));
+ if (wpt->speed_has_value()) {
+ gpssim_write_spd(MPS_TO_KNOTS(wpt->speed_value()));
}
double lat = degrees2ddmm(wpt->latitude);
*/
case tt_humminbird_wpt_depth:
case tt_humminbird_trk_trkseg_trkpt_depth:
- WAYPT_SET(wpt_tmp, depth, cdatastr.toDouble() / 100.0);
+ wpt_tmp->set_depth(cdatastr.toDouble() / 100.0);
break;
/*
* Route-specific tags.
trk_head->rte_num = cdatastr.toInt();
break;
case tt_trk_trkseg_trkpt_course:
- WAYPT_SET(wpt_tmp, course, cdatastr.toDouble());
+ wpt_tmp->set_course(cdatastr.toDouble());
break;
case tt_trk_trkseg_trkpt_speed:
- WAYPT_SET(wpt_tmp, speed, cdatastr.toDouble());
+ wpt_tmp->set_speed(cdatastr.toDouble());
break;
case tt_trk_trkseg_trkpt_heartrate:
wpt_tmp->heartrate = cdatastr.toDouble();
wpt_tmp->SetCreationTime(xml_parse_time(cdatastr));
break;
case tt_wpttype_geoidheight:
- WAYPT_SET(wpt_tmp, geoidheight, cdatastr.toDouble());
+ wpt_tmp->set_geoidheight(cdatastr.toDouble());
break;
case tt_wpttype_cmt:
wpt_tmp->description = cdatastr;
writer->writeOptionalTextElement(QStringLiteral("time"), t);
if (gpxpt_track==point_type && gpx_1_0 == gpx_write_version) {
/* These were accidentally removed from 1.1, and were only a part of trkpts in 1.0 */
- if WAYPT_HAS(waypointp, course) {
- writer->writeTextElement(QStringLiteral("course"), toString(waypointp->course));
+ if (waypointp->course_has_value()) {
+ writer->writeTextElement(QStringLiteral("course"), toString(waypointp->course_value()));
}
- if WAYPT_HAS(waypointp, speed) {
- writer->writeTextElement(QStringLiteral("speed"), toString(waypointp->speed));
+ if (waypointp->speed_has_value()) {
+ writer->writeTextElement(QStringLiteral("speed"), toString(waypointp->speed_value()));
}
}
/* TODO: magvar should go here */
- if (WAYPT_HAS(waypointp, geoidheight)) {
- writer->writeOptionalTextElement(QStringLiteral("geoidheight"),QString::number(waypointp->geoidheight, 'f', 1));
+ if (waypointp->geoidheight_has_value()) {
+ writer->writeOptionalTextElement(QStringLiteral("geoidheight"),QString::number(waypointp->geoidheight_value(), 'f', 1));
}
}
// gpx version we are writing is >= 1.1.
garmin_fs_t* gmsd = (opt_garminext) ? garmin_fs_t::find(waypointp) : nullptr; // only needed if garmin extensions selected
- if ((opt_humminbirdext && (WAYPT_HAS(waypointp, depth) || WAYPT_HAS(waypointp, temperature))) ||
+ if ((opt_humminbirdext && (waypointp->depth_has_value() || waypointp->temperature_has_value())) ||
(opt_garminext && gpxpt_route==point_type && gmsd != nullptr && gmsd->ilinks != nullptr) ||
- (opt_garminext && gpxpt_waypoint==point_type && (WAYPT_HAS(waypointp, proximity) || WAYPT_HAS(waypointp, temperature) || WAYPT_HAS(waypointp, depth))) ||
- (opt_garminext && gpxpt_track==point_type && (WAYPT_HAS(waypointp, temperature) || WAYPT_HAS(waypointp, depth) || waypointp->heartrate != 0 || waypointp->cadence != 0))) {
+ (opt_garminext && gpxpt_waypoint==point_type && (waypointp->proximity_has_value() || waypointp->temperature_has_value() || waypointp->depth_has_value())) ||
+ (opt_garminext && gpxpt_track==point_type && (waypointp->temperature_has_value() || waypointp->depth_has_value() || waypointp->heartrate != 0 || waypointp->cadence != 0))) {
writer->writeStartElement(QStringLiteral("extensions"));
if (opt_humminbirdext) {
- if (WAYPT_HAS(waypointp, depth)) {
- writer->writeTextElement(QStringLiteral("h:depth"), toString(waypointp->depth * 100.0));
+ if (waypointp->depth_has_value()) {
+ writer->writeTextElement(QStringLiteral("h:depth"), toString(waypointp->depth_value() * 100.0));
}
- if (WAYPT_HAS(waypointp, temperature)) {
- writer->writeTextElement(QStringLiteral("h:temperature"), toString(waypointp->temperature));
+ if (waypointp->temperature_has_value()) {
+ writer->writeTextElement(QStringLiteral("h:temperature"), toString(waypointp->temperature_value()));
}
}
// Although not required by the schema we assume that gpxtpx:TrackPointExtension must be a child of gpx:trkpt.
switch (point_type) {
case gpxpt_waypoint:
- if (WAYPT_HAS(waypointp, proximity) || WAYPT_HAS(waypointp, temperature) || WAYPT_HAS(waypointp, depth)) {
+ if (waypointp->proximity_has_value() || waypointp->temperature_has_value() || waypointp->depth_has_value()) {
writer->writeStartElement(QStringLiteral("gpxx:WaypointExtension"));
- if (WAYPT_HAS(waypointp, proximity)) {
- writer->writeTextElement(QStringLiteral("gpxx:Proximity"), toString(waypointp->proximity));
+ if (waypointp->proximity_has_value()) {
+ writer->writeTextElement(QStringLiteral("gpxx:Proximity"), toString(waypointp->proximity_value()));
}
- if (WAYPT_HAS(waypointp, temperature)) {
- writer->writeTextElement(QStringLiteral("gpxx:Temperature"), toString(waypointp->temperature));
+ if (waypointp->temperature_has_value()) {
+ writer->writeTextElement(QStringLiteral("gpxx:Temperature"), toString(waypointp->temperature_value()));
}
- if (WAYPT_HAS(waypointp, depth)) {
- writer->writeTextElement(QStringLiteral("gpxx:Depth"), toString(waypointp->depth));
+ if (waypointp->depth_has_value()) {
+ writer->writeTextElement(QStringLiteral("gpxx:Depth"), toString(waypointp->depth_value()));
}
writer->writeEndElement(); // "gpxx:WaypointExtension"
}
}
break;
case gpxpt_track:
- if (WAYPT_HAS(waypointp, temperature) || WAYPT_HAS(waypointp, depth) || waypointp->heartrate != 0 || waypointp->cadence != 0) {
+ if (waypointp->temperature_has_value() || waypointp->depth_has_value() || waypointp->heartrate != 0 || waypointp->cadence != 0) {
// gpxtpx:TrackPointExtension is a replacement for gpxx:TrackPointExtension.
writer->writeStartElement(QStringLiteral("gpxtpx:TrackPointExtension"));
- if (WAYPT_HAS(waypointp, temperature)) {
- writer->writeTextElement(QStringLiteral("gpxtpx:atemp"), toString(waypointp->temperature));
+ if (waypointp->temperature_has_value()) {
+ writer->writeTextElement(QStringLiteral("gpxtpx:atemp"), toString(waypointp->temperature_value()));
}
- if (WAYPT_HAS(waypointp, depth)) {
- writer->writeTextElement(QStringLiteral("gpxtpx:depth"), toString(waypointp->depth));
+ if (waypointp->depth_has_value()) {
+ writer->writeTextElement(QStringLiteral("gpxtpx:depth"), toString(waypointp->depth_value()));
}
if (waypointp->heartrate != 0) {
writer->writeTextElement(QStringLiteral("gpxtpx:hr"), QString::number(waypointp->heartrate));
if (wpt->cadence) {
gtc_write_xml(0, "<Cadence>%d</Cadence>\n", wpt->cadence);
}
- if (WAYPT_HAS(wpt, speed) || wpt->power) {
+ if (wpt->speed_has_value() || wpt->power) {
gtc_write_xml(1, "<Extensions>\n");
gtc_write_xml(1, "<TPX xmlns=\"http://www.garmin.com/xmlschemas/ActivityExtension/v2\">\n");
/* see http://www8.garmin.com/xmlschemas/ActivityExtensionv2.xsd */
- if (WAYPT_HAS(wpt, speed)) {
- gtc_write_xml(0, "<Speed>%.3f</Speed>\n", wpt->speed);
+ if (wpt->speed_has_value()) {
+ gtc_write_xml(0, "<Speed>%.3f</Speed>\n", wpt->speed_value());
}
if (wpt->power) {
gtc_write_xml(0, "<Watts>%.0f</Watts>\n", wpt->power);
void
GtrnctrFormat::gtc_trk_spd(xg_string args, const QXmlStreamAttributes* /*unused*/)
{
- WAYPT_SET(wpt_tmp, speed, args.toDouble());
+ wpt_tmp->set_speed(args.toDouble());
}
void
wpt->altitude = 0.0; /* It's from a fishfinder... */
if (w.depth != 0) {
- WAYPT_SET(wpt,depth,(double)w.depth / 100.0);
+ wpt->set_depth((double)w.depth / 100.0);
}
int num_icons = sizeof(humminbird_icons) / sizeof(humminbird_icons[0]);
wpt->altitude = 0.0;
if (points[i].depth != 0) {
- WAYPT_SET(wpt,depth,(double)points[i].depth / 100.0);
+ wpt->set_depth((double)points[i].depth / 100.0);
}
if (i == th.num_points-2 && th.time != 0) {
}
}
- hum.depth = qRound(WAYPT_GET(wpt, depth, 0)*100.0);
+ hum.depth = qRound(wpt->depth_value_or(0) * 100.0);
be_write16(&hum.depth, hum.depth);
be_write32(&hum.time, wpt->GetCreationTime().toTime_t());
int j = i-1;
trk_points[j].deltaeast = east - last_east;
trk_points[j].deltanorth = north - last_north;
- trk_points[j].depth = qRound(WAYPT_GET(wpt, depth, 0)*100.0);
+ trk_points[j].depth = qRound(wpt->depth_value_or(0) * 100.0);
/* BE-ify */
be_write16(&trk_points[j].deltaeast, trk_points[j].deltaeast);
}
/* Which unit is this temp in? C? F? K? */
- if WAYPT_HAS(pt, temperature) {
- kml_td(hwriter, QStringLiteral("Temperature: %1 ").arg(QString::number(pt->temperature, 'f', 1)));
+ if (pt->temperature_has_value()) {
+ kml_td(hwriter, QStringLiteral("Temperature: %1 ").arg(QString::number(pt->temperature_value(), 'f', 1)));
}
- if WAYPT_HAS(pt, depth) {
- auto [depth, depth_units] = unitsformatter->fmt_distance(pt->depth);
+ if (pt->depth_has_value()) {
+ auto [depth, depth_units] = unitsformatter->fmt_distance(pt->depth_value());
kml_td(hwriter, QStringLiteral("Depth: %1 %2 ").arg(QString::number(depth, 'f', 1), depth_units));
}
- if WAYPT_HAS(pt, speed) {
- auto [spd, spd_units] = unitsformatter->fmt_speed(pt->speed);
+ if (pt->speed_has_value()) {
+ auto [spd, spd_units] = unitsformatter->fmt_speed(pt->speed_value());
kml_td(hwriter, QStringLiteral("Speed: %1 %2 ").arg(QString::number(spd, 'f', 1), spd_units));
}
- if WAYPT_HAS(pt, course) {
- kml_td(hwriter, QStringLiteral("Heading: %1 ").arg(QString::number(pt->course, 'f', 1)));
+ if (pt->course_has_value()) {
+ kml_td(hwriter, QStringLiteral("Heading: %1 ").arg(QString::number(pt->course_value(), 'f', 1)));
}
/* This really shouldn't be here, but as of this writing,
} else {
if (trackdirection && (pt_type == kmlpt_track)) {
QString value;
- if (!WAYPT_HAS(waypointp, speed) || !WAYPT_HAS(waypointp, course) ||
- (waypointp->speed < 1.0f)) {
+ if (!waypointp->speed_has_value() || !waypointp->course_has_value() ||
+ (waypointp->speed_value() < 1.0f)) {
value = QStringLiteral("%1-none").arg(style);
} else {
value = QStringLiteral("%1-%2").arg(style)
- .arg(qRound(waypointp->course / 22.5) % 16);
+ .arg(qRound(waypointp->course_value() / 22.5) % 16);
}
writer->writeTextElement(QStringLiteral("styleUrl"), value);
} else {
QString::number(wpt->cadence) : QString());
break;
case fld_depth:
- writer->writeTextElement(QStringLiteral("gx:value"), WAYPT_HAS(wpt, depth)?
- QString::number(wpt->depth, 'f', 1) : QString());
+ writer->writeTextElement(QStringLiteral("gx:value"), wpt->depth_has_value()?
+ QString::number(wpt->depth_value(), 'f', 1) : QString());
break;
case fld_heartrate:
writer->writeTextElement(QStringLiteral("gx:value"), wpt->heartrate?
QString::number(wpt->heartrate) : QString());
break;
case fld_temperature:
- writer->writeTextElement(QStringLiteral("gx:value"), WAYPT_HAS(wpt, temperature)?
- QString::number(wpt->temperature, 'f', 1) : QString());
+ writer->writeTextElement(QStringLiteral("gx:value"), wpt->temperature_has_value()?
+ QString::number(wpt->temperature_value(), 'f', 1) : QString());
break;
default:
fatal("Bad member type");
if (tpt->cadence) {
has_cadence = true;
}
- if (WAYPT_HAS(tpt, depth)) {
+ if (tpt->depth_has_value()) {
has_depth = true;
}
if (tpt->heartrate) {
has_heartrate = true;
}
- if (WAYPT_HAS(tpt, temperature)) {
+ if (tpt->temperature_has_value()) {
has_temperature = true;
}
if (tpt->power) {
if (reading_version == 3) {
float depth_feet = gbfgetflt(file_in);
if (std::abs(depth_feet - 99999.0) > .1) {
- WAYPT_SET(wpt_tmp, depth, FEET_TO_METERS(depth_feet));
+ wpt_tmp->set_depth(FEET_TO_METERS(depth_feet));
if (global_opts.debug_level == 99) {
printf(" %10.1f", depth_feet);
}
/* Alarm radius; XXX: I'm not sure what the units are here,
assuming meters but may be feet? */
- WAYPT_SET(wpt_tmp, proximity, gbfgetflt(file_in));
+ wpt_tmp->set_proximity(gbfgetflt(file_in));
/* Creation date/time */
/* The date is a Julian day number, and the time is a unix timestamp. */
gbfputint16(WayptType, file_out);
if (writing_version == 3) {
- float depth = WAYPT_HAS(wpt, depth) ?
- METERS_TO_FEET(wpt->depth) : -99999.0;
+ float depth = wpt->depth_has_value() ?
+ METERS_TO_FEET(wpt->depth_value()) : -99999.0;
gbfputint32(depth, file_out);
}
lowranceusr4_writestr(wpt->description, file_out, 2);
/* Alarm radius */
- gbfputflt(WAYPT_GET(wpt, proximity, 0.0), file_out);
+ gbfputflt(wpt->proximity_value_or(0.0), file_out);
/* Creation date/time */
auto ts = lowranceusr4_jd_from_timestamp(wpt->GetCreationTime());
}
if (bmask & (1U<<HEADING)) {
- WAYPT_SET(trk, course, itm->heading);
+ trk->set_course(itm->heading);
}
if (bmask & (1U<<SPEED)) {
- WAYPT_SET(trk, speed, KPH_TO_MPS(itm->speed));
+ trk->set_speed(KPH_TO_MPS(itm->speed));
}
if (bmask & (1U<<VALID)) {
switch (itm->valid) {
decode_position(buffer + 12, waypt);
waypt->SetCreationTime(decode_datetime(buffer + 22));
- WAYPT_SET(waypt, course, le_read16(buffer + 2));
- WAYPT_SET(waypt, speed, KPH_TO_MPS(buffer[29] * 2));
+ waypt->set_course(le_read16(buffer + 2));
+ waypt->set_speed(KPH_TO_MPS(buffer[29] * 2));
return waypt;
}
GPS_Math_WGS84_To_UTM_EN(waypt->latitude, waypt->longitude, &x, &y, &z, &zc);
le_write16(buffer + 0, serial);
- le_write16(buffer + 2, WAYPT_GET(waypt, course, 0));
+ le_write16(buffer + 2, waypt->course_value_or(0));
le_write32(buffer + 4, x);
le_write32(buffer + 8, y);
encode_position(waypt, buffer + 12);
encode_datetime(waypt->GetCreationTime().toTime_t(), buffer + 22);
buffer[28] = z;
- buffer[29] = MPS_TO_KPH(WAYPT_GET(waypt, speed, 0) / 2);
+ buffer[29] = MPS_TO_KPH(waypt->speed_value_or(0) / 2);
buffer[30] = 0x5a;
buffer[31] = 0x7e;
}
waypt->SetCreationTime(decode_sbp_datetime_packed(buffer + 4),
decode_sbp_msec(buffer + 2));
decode_sbp_position(buffer + 12, waypt);
- WAYPT_SET(waypt, speed, le_read16(buffer + 24) * 0.01f);
- WAYPT_SET(waypt, course, le_read16(buffer + 26) * 0.01f);
+ waypt->set_speed(le_read16(buffer + 24) * 0.01f);
+ waypt->set_course(le_read16(buffer + 26) * 0.01f);
return waypt;
}
waypt->altitude = alt;
- WAYPT_SET(waypt, geoidheight, geoidheight);
+ waypt->set_geoidheight(geoidheight);
waypt->sat = nsats;
if (posn_type == gpgga) {
/* capture useful data update and exit */
if (curr_waypt) {
- if (! WAYPT_HAS(curr_waypt, speed)) {
- WAYPT_SET(curr_waypt, speed, KNOTS_TO_MPS(speed));
+ if (!curr_waypt->speed_has_value()) {
+ curr_waypt->set_speed(KNOTS_TO_MPS(speed));
}
- if (! WAYPT_HAS(curr_waypt, course)) {
- WAYPT_SET(curr_waypt, course, course);
+ if (!curr_waypt->course_has_value()) {
+ curr_waypt->set_course(course);
}
/* The change of date wasn't recorded when
* going from 235959 to 000000. */
Waypoint* waypt = nmea_new_wpt();
- WAYPT_SET(waypt, speed, KNOTS_TO_MPS(speed));
- WAYPT_SET(waypt, course, course);
+ waypt->set_speed(KNOTS_TO_MPS(speed));
+ waypt->set_course(course);
nmea_set_waypoint_time(waypt, &prev_datetime, dmy, hms);
if (fields.size() > 7) speed_k = fields[7].toDouble();
if (curr_waypt) {
- WAYPT_SET(curr_waypt, course, course);
+ curr_waypt->set_course(course);
if (speed_k > 0) {
- WAYPT_SET(curr_waypt, speed, KPH_TO_MPS(speed_k));
+ curr_waypt->set_speed(KPH_TO_MPS(speed_k));
} else {
- WAYPT_SET(curr_waypt, speed, KNOTS_TO_MPS(speed_n));
+ curr_waypt->set_speed(KNOTS_TO_MPS(speed_n));
}
}
fix=='0' ? 'V' : 'A',
fabs(lat), lat < 0 ? 'S' : 'N',
fabs(lon), lon < 0 ? 'W' : 'E',
- WAYPT_HAS(wpt, speed) ? MPS_TO_KNOTS(wpt->speed):(0),
- WAYPT_HAS(wpt, course) ? (wpt->course):(0),
+ wpt->speed_has_value() ? MPS_TO_KNOTS(wpt->speed_value()):(0),
+ wpt->course_value_or(0),
dmy.constData());
cksum = nmea_cksum(obuf);
(wpt->sat>0)?(wpt->sat):(0),
(wpt->hdop>0)?(wpt->hdop):(0.0),
wpt->altitude == unknown_alt ? 0 : wpt->altitude,
- WAYPT_HAS(wpt, geoidheight)? (wpt->geoidheight) : (0)); /* TODO: we could look up the geoidheight if needed */
+ wpt->geoidheight_value_or(0)); /* TODO: we could look up the geoidheight if needed */
cksum = nmea_cksum(obuf);
gbfprintf(file_out, "$%s*%02X\n", obuf, cksum);
}
- if ((opt_gpvtg) && (WAYPT_HAS(wpt, course) || WAYPT_HAS(wpt, speed))) {
+ if ((opt_gpvtg) && (wpt->course_has_value() || wpt->speed_has_value())) {
snprintf(obuf,sizeof(obuf),"GPVTG,%.3f,T,0,M,%.3f,N,%.3f,K",
- WAYPT_HAS(wpt, course) ? (wpt->course):(0),
- WAYPT_HAS(wpt, speed) ? MPS_TO_KNOTS(wpt->speed):(0),
- WAYPT_HAS(wpt, speed) ? MPS_TO_KPH(wpt->speed):(0));
+ wpt->course_value_or(0),
+ wpt->speed_has_value() ? MPS_TO_KNOTS(wpt->speed_value()):(0),
+ wpt->speed_has_value() ? MPS_TO_KPH(wpt->speed_value()):(0));
cksum = nmea_cksum(obuf);
gbfprintf(file_out, "$%s*%02X\n", obuf, cksum);
break;
case 13:
/* proximity distance - meters */
- WAYPT_SET(wpt_tmp, proximity, str.toDouble() * prox_scale);
+ wpt_tmp->set_proximity(str.toDouble() * prox_scale);
break;
case 14:
/* altitude */
<< fs->fgcolor << ','
<< fs->bgcolor << ','
<< description << ",0,0,";
- if (WAYPT_HAS(wpt, proximity) && (wpt->proximity > 0)) {
- *stream << qSetRealNumberPrecision(1) << wpt->proximity * prox_scale << ',';
+ if (wpt->proximity_has_value() && (wpt->proximity_value() > 0)) {
+ *stream << qSetRealNumberPrecision(1) << wpt->proximity_value() * prox_scale << ',';
} else if (proximity > 0) {
*stream << qSetRealNumberPrecision(1) << proximity * prox_scale << ',';
} else {
waypoint->fix = fix;
waypoint->sat = satelliteCountUsed;
- WAYPT_SET(waypoint, speed, KPH_TO_MPS(speed));
+ waypoint->set_speed(KPH_TO_MPS(speed));
- WAYPT_SET(waypoint, course, heading);
+ waypoint->set_course(heading);
waypoint->SetCreationTime(time, milliseconds);
auto* fsdata = new qstarz_bl_1000_fsdata;
wpt->altitude = rand_dbl(100.0);
}
if RND(3) {
- WAYPT_SET(wpt, temperature, rand_flt(32.0f));
+ wpt->set_temperature(rand_flt(32.0f));
}
if RND(3) {
- WAYPT_SET(wpt, proximity, rand_dbl(1000.0));
+ wpt->set_proximity(rand_dbl(1000.0));
}
if RND(3) {
- WAYPT_SET(wpt, depth, rand_dbl(1000.0));
+ wpt->set_depth(rand_dbl(1000.0));
}
if RND(3) {
wpt->AddUrlLink(rand_str(8, "http://link1.example.com/%s"));
if (i > 0) {
wpt->latitude = prev->latitude + rand_dbl(0.001);
wpt->longitude = prev->longitude + rand_dbl(0.001);
- WAYPT_SET(wpt, course, waypt_course(prev, wpt));
- WAYPT_SET(wpt, speed, waypt_speed(prev, wpt));
+ wpt->set_course(waypt_course(prev, wpt));
+ wpt->set_speed(waypt_speed(prev, wpt));
}
wpt->sat = rand_int(12 + 1);
wpt->hdop = rand_flt(50.0f);
double tlon = RAD(thisw->longitude);
double plat = RAD(prev->latitude);
double plon = RAD(prev->longitude);
- WAYPT_SET(thisw, course, heading_true_degrees(plat, plon,
- tlat, tlon));
+ thisw->set_course(heading_true_degrees(plat, plon, tlat, tlon));
double dist = radtometers(gcdist(plat, plon, tlat, tlon));
/*
* If we've moved as much as a meter,
* conditionally recompute speeds.
*/
- if (!WAYPT_HAS(thisw, speed) && (dist > 1)) {
+ if (!thisw->speed_has_value() && (dist > 1)) {
// Only recompute speed if the waypoint
// didn't already have a speed
if (thisw->GetCreationTime().isValid() &&
thisw->GetCreationTime() > prev->GetCreationTime()) {
double timed =
prev->GetCreationTime().msecsTo(thisw->GetCreationTime()) / 1000.0;
- WAYPT_SET(thisw, speed, dist / timed);
+ thisw->set_speed(dist / timed);
}
}
- if (WAYPT_HAS(thisw, speed)) {
- if ((!tdata.min_spd) || (thisw->speed < tdata.min_spd)) {
- tdata.min_spd = thisw->speed;
+ if (thisw->speed_has_value()) {
+ if ((!tdata.min_spd) || (thisw->speed_value() < tdata.min_spd)) {
+ tdata.min_spd = thisw->speed_value();
}
- if ((!tdata.max_spd) || (thisw->speed > tdata.max_spd)) {
- tdata.max_spd = thisw->speed;
+ if ((!tdata.max_spd) || (thisw->speed_value() > tdata.max_spd)) {
+ tdata.max_spd = thisw->speed_value();
}
}
decode_sbn_datetime(buffer + 10, waypt);
decode_sbn_position(buffer + 22, waypt);
- WAYPT_SET(waypt, speed, be_read16(buffer + 39) * 0.01f);
- WAYPT_SET(waypt, course, be_read16(buffer + 41) * 0.01f);
+ waypt->set_speed(be_read16(buffer + 39) * 0.01f);
+ waypt->set_course(be_read16(buffer + 41) * 0.01f);
waypt->sat = buffer[87];
waypt->hdop = buffer[88] * 0.2f;
alt = m.alt * POW_2_M7;
tpt = make_trackpoint(pst, lat, lon, alt);
- WAYPT_SET(tpt, speed, spe); /* convert speed to m/s */
+ tpt->set_speed(spe); /* convert speed to m/s */
track_add_wpt(pst->route_head_, tpt);
res = MULTI_HZ_ITEM_LEN;
ECEF_to_LLA(pst->x, pst->y, pst->z, &lat, &lon, &alt);
// GPS_Math_XYZ_To_WGS84LatLonH(&lat, &lon, &alt, pst->x, pst->y, pst->z);
tpt = make_trackpoint(pst, lat, lon, alt);
- WAYPT_SET(tpt, speed, KPH_TO_MPS(ITEM_SPEED(pitem))); /* convert speed to m/s */
+ tpt->set_speed(KPH_TO_MPS(ITEM_SPEED(pitem))); /* convert speed to m/s */
if (poi) {
waypt_add(new Waypoint(*tpt));
switch (fmt) {
case 's':
- if WAYPT_HAS(prevwpp, speed) {
- gbfprintf(fout, "%2.1f", MPS_TO_KPH(prevwpp->speed));
+ if (prevwpp->speed_has_value()) {
+ gbfprintf(fout, "%2.1f", MPS_TO_KPH(prevwpp->speed_value()));
} else {
gbfprintf(fout, "--.-");
}
if (first) {
if (opt_course) {
// TODO: the course value 0 isn't valid, wouldn't it be better to UNSET course?
- WAYPT_SET(wpt, course, 0);
+ wpt->set_course(0);
}
if (opt_speed) {
// TODO: the speed value 0 isn't valid, wouldn't it be better to UNSET speed?
- WAYPT_SET(wpt, speed, 0);
+ wpt->set_speed(0);
}
first = false;
last_course_lat = wpt->latitude;
last_speed_time = wpt->GetCreationTime();
} else {
if (opt_course) {
- WAYPT_SET(wpt, course, heading_true_degrees(RAD(last_course_lat),
- RAD(last_course_lon),RAD(wpt->latitude),
- RAD(wpt->longitude)));
+ wpt->set_course(heading_true_degrees(RAD(last_course_lat),
+ RAD(last_course_lon),RAD(wpt->latitude),
+ RAD(wpt->longitude)));
last_course_lat = wpt->latitude;
last_course_lon = wpt->longitude;
}
// Note that points with the same time can occur because the input
// has truncated times, or because we are truncating times with
// toTime_t().
- WAYPT_SET(wpt, speed, radtometers(gcdist(
- RAD(last_speed_lat), RAD(last_speed_lon),
- RAD(wpt->latitude),
- RAD(wpt->longitude))) /
- (0.001 * std::abs(last_speed_time.msecsTo(wpt->GetCreationTime())))
- );
+ wpt->set_speed(radtometers(gcdist(
+ RAD(last_speed_lat), RAD(last_speed_lon),
+ RAD(wpt->latitude),
+ RAD(wpt->longitude))) /
+ (0.001 * std::abs(last_speed_time.msecsTo(wpt->GetCreationTime())))
+ );
last_speed_lat = wpt->latitude;
last_speed_lon = wpt->longitude;
last_speed_time = wpt->GetCreationTime();
} else {
- WAYPT_UNSET(wpt, speed);
+ wpt->reset_speed();
}
}
}
std::abs(wpta->latitude - wptb->latitude) < .00001 &&
std::abs(wpta->longitude - wptb->longitude) < .00001 &&
std::abs(wpta->altitude - wptb->altitude) < 20 &&
- WAYPT_EQUAL(wpta, wptb, course) &&
- WAYPT_EQUAL(wpta, wptb, speed) &&
+ wpta->courses_equal(*wptb) &&
+ wpta->speeds_equal(*wptb) &&
(wpta->heartrate == wptb->heartrate) &&
(wpta->cadence == wptb->cadence) &&
- WAYPT_EQUAL(wpta, wptb, temperature);
+ wpta->temperatures_equal(*wptb);
}
void TrackFilter::trackfilter_segment_head(const route_head* rte)
case fld_speed:
if (parse_speed(value, &d, 1.0, MYNAME)) {
- WAYPT_SET(wpt, speed, d);
+ wpt->set_speed(d);
if (unicsv_detect) {
unicsv_data_type = trkdata;
}
break;
case fld_course:
- WAYPT_SET(wpt, course, value.toDouble());
+ wpt->set_course(value.toDouble());
if (unicsv_detect) {
unicsv_data_type = trkdata;
}
case fld_temperature:
d = value.toDouble();
if (fabs(d) < 999999) {
- WAYPT_SET(wpt, temperature, d);
+ wpt->set_temperature(d);
}
break;
case fld_temperature_f:
d = value.toDouble();
if (fabs(d) < 999999) {
- WAYPT_SET(wpt, temperature, FAHRENHEIT_TO_CELSIUS(d));
+ wpt->set_temperature(FAHRENHEIT_TO_CELSIUS(d));
}
break;
case fld_proximity:
if (parse_distance(value, &d, unicsv_proximityscale, MYNAME)) {
- WAYPT_SET(wpt, proximity, d);
+ wpt->set_proximity(d);
}
break;
case fld_depth:
if (parse_distance(value, &d, unicsv_depthscale, MYNAME)) {
- WAYPT_SET(wpt, depth, d);
+ wpt->set_depth(d);
}
break;
}
/* "flagged" waypoint members */
- if WAYPT_HAS(wpt, course) {
+ if (wpt->course_has_value()) {
gb_setbit(&unicsv_outp_flags, fld_course);
}
- if WAYPT_HAS(wpt, depth) {
+ if (wpt->depth_has_value()) {
gb_setbit(&unicsv_outp_flags, fld_depth);
}
- if WAYPT_HAS(wpt, speed) {
+ if (wpt->speed_has_value()) {
gb_setbit(&unicsv_outp_flags, fld_speed);
}
- if WAYPT_HAS(wpt, proximity) {
+ if (wpt->proximity_has_value()) {
gb_setbit(&unicsv_outp_flags, fld_proximity);
}
- if WAYPT_HAS(wpt, temperature) {
+ if (wpt->temperature_has_value()) {
gb_setbit(&unicsv_outp_flags, fld_temperature);
}
unicsv_print_str(wpt->icon_descr.isNull() ? "Waypoint" : wpt->icon_descr);
}
if FIELD_USED(fld_depth) {
- if WAYPT_HAS(wpt, depth) {
+ if (wpt->depth_has_value()) {
*fout << unicsv_fieldsep
- << qSetRealNumberPrecision(3) << wpt->depth;
+ << qSetRealNumberPrecision(3) << wpt->depth_value();
} else {
*fout << unicsv_fieldsep;
}
}
if FIELD_USED(fld_proximity) {
- if WAYPT_HAS(wpt, proximity) {
+ if (wpt->proximity_has_value()) {
*fout << unicsv_fieldsep
- << qSetRealNumberPrecision(0) << wpt->proximity;
+ << qSetRealNumberPrecision(0) << wpt->proximity_value();
} else {
*fout << unicsv_fieldsep;
}
}
if FIELD_USED(fld_temperature) {
- if WAYPT_HAS(wpt, temperature) {
+ if (wpt->temperature_has_value()) {
*fout << unicsv_fieldsep
- << qSetRealNumberPrecision(3) << wpt->temperature;
+ << qSetRealNumberPrecision(3) << wpt->temperature_value();
} else {
*fout << unicsv_fieldsep;
}
}
if FIELD_USED(fld_speed) {
- if WAYPT_HAS(wpt, speed) {
+ if (wpt->speed_has_value()) {
*fout << unicsv_fieldsep
- << qSetRealNumberPrecision(2) << wpt->speed;
+ << qSetRealNumberPrecision(2) << wpt->speed_value();
} else {
*fout << unicsv_fieldsep;
}
}
if FIELD_USED(fld_course) {
- if WAYPT_HAS(wpt, course) {
+ if (wpt->course_has_value()) {
*fout << unicsv_fieldsep
- << qSetRealNumberPrecision(1) << wpt->course;
+ << qSetRealNumberPrecision(1) << wpt->course_value();
} else {
*fout << unicsv_fieldsep;
}
wpt->SetCreationTime(bintime2utc(date, time));
}
- WAYPT_SET(wpt, speed, KPH_TO_MPS(xstrtoi(line.bas.common.speed, nullptr, 10)));
+ wpt->set_speed(KPH_TO_MPS(xstrtoi(line.bas.common.speed, nullptr, 10)));
- WAYPT_SET(wpt, course, xstrtoi(line.bas.common.heading, nullptr, 10));
+ wpt->set_course(xstrtoi(line.bas.common.heading, nullptr, 10));
if (is_advanced_mode) {
wpt->hdop = strtod(line.adv.hdop, nullptr);
traits.trait_heartrate |= wpt->heartrate > 0;
traits.trait_cadence |= wpt->cadence > 0;
traits.trait_power |= wpt->power > 0;
- traits.trait_depth |= WAYPT_HAS(wpt, depth);
- traits.trait_temperature |= WAYPT_HAS(wpt, temperature);
+ traits.trait_depth |= wpt->depth_has_value();
+ traits.trait_temperature |= wpt->temperature_has_value();
}
void
}
Waypoint::Waypoint() :
- latitude(0), // These should probably use some invalid data, but
- longitude(0), // it looks like we have code that relies on them being zero.
- altitude(unknown_alt),
geoidheight(0),
depth(0),
proximity(0),
+ course(0),
+ speed(0),
+ temperature(0),
+ latitude(0), // These should probably use some invalid data, but
+ longitude(0), // it looks like we have code that relies on them being zero.
+ altitude(unknown_alt),
route_priority(0),
hdop(0),
vdop(0),
pdop(0),
- course(0),
- speed(0),
fix(fix_unknown),
sat(-1),
heartrate(0),
cadence(0),
power(0),
- temperature(0),
odometer_distance(0),
gc_data(&Waypoint::empty_gc_data),
session(curr_session()),
}
Waypoint::Waypoint(const Waypoint& other) :
- latitude(other.latitude),
- longitude(other.longitude),
- altitude(other.altitude),
geoidheight(other.geoidheight),
depth(other.depth),
proximity(other.proximity),
+ course(other.course),
+ speed(other.speed),
+ temperature(other.temperature),
+ opt_flags(other.opt_flags),
+ latitude(other.latitude),
+ longitude(other.longitude),
+ altitude(other.altitude),
shortname(other.shortname),
description(other.description),
notes(other.notes),
urls(other.urls),
- wpt_flags(other.wpt_flags),
icon_descr(other.icon_descr),
creation_time(other.creation_time),
+ wpt_flags(other.wpt_flags),
route_priority(other.route_priority),
hdop(other.hdop),
vdop(other.vdop),
pdop(other.pdop),
- course(other.course),
- speed(other.speed),
fix(other.fix),
sat(other.sat),
heartrate(other.heartrate),
cadence(other.cadence),
power(other.power),
- temperature(other.temperature),
odometer_distance(other.odometer_distance),
gc_data(other.gc_data),
session(other.session),
/* PATH CONVERSIONS ************************************************/
case XcsvStyle::XT_PATH_SPEED:
- WAYPT_SET(wpt, speed, strtod(s, nullptr));
+ wpt->set_speed(strtod(s, nullptr));
break;
case XcsvStyle::XT_PATH_SPEED_KPH:
- WAYPT_SET(wpt, speed, KPH_TO_MPS(strtod(s, nullptr)));
+ wpt->set_speed(KPH_TO_MPS(strtod(s, nullptr)));
break;
case XcsvStyle::XT_PATH_SPEED_MPH:
- WAYPT_SET(wpt, speed, MPH_TO_MPS(strtod(s, nullptr)));
+ wpt->set_speed(MPH_TO_MPS(strtod(s, nullptr)));
break;
case XcsvStyle::XT_PATH_SPEED_KNOTS:
- WAYPT_SET(wpt, speed, KNOTS_TO_MPS(strtod(s, nullptr)));
+ wpt->set_speed(KNOTS_TO_MPS(strtod(s, nullptr)));
break;
case XcsvStyle::XT_PATH_COURSE:
- WAYPT_SET(wpt, course, strtod(s, nullptr));
+ wpt->set_course(strtod(s, nullptr));
break;
/* TIME CONVERSIONS ***************************************************/
wpt->power = strtod(s, nullptr);
break;
case XcsvStyle::XT_TEMPERATURE:
- WAYPT_SET(wpt, temperature, strtod(s, nullptr));
+ wpt->set_temperature(strtod(s, nullptr));
break;
case XcsvStyle::XT_TEMPERATURE_F:
- WAYPT_SET(wpt, temperature, FAHRENHEIT_TO_CELSIUS(strtod(s, nullptr)));
+ wpt->set_temperature(FAHRENHEIT_TO_CELSIUS(strtod(s, nullptr)));
break;
/* GMSD ****************************************************************/
case XcsvStyle::XT_COUNTRY: {
}
break;
case XcsvStyle::XT_PATH_SPEED:
- if (WAYPT_HAS(wpt, speed)) {
- buff = QString::asprintf(fmp.printfc.constData(), wpt->speed);
+ if (wpt->speed_has_value()) {
+ buff = QString::asprintf(fmp.printfc.constData(), wpt->speed_value());
}
break;
case XcsvStyle::XT_PATH_SPEED_KPH:
- if (WAYPT_HAS(wpt, speed)) {
- buff = QString::asprintf(fmp.printfc.constData(), MPS_TO_KPH(wpt->speed));
+ if (wpt->speed_has_value()) {
+ buff = QString::asprintf(fmp.printfc.constData(), MPS_TO_KPH(wpt->speed_value()));
}
break;
case XcsvStyle::XT_PATH_SPEED_MPH:
- if (WAYPT_HAS(wpt, speed)) {
- buff = QString::asprintf(fmp.printfc.constData(), MPS_TO_MPH(wpt->speed));
+ if (wpt->speed_has_value()) {
+ buff = QString::asprintf(fmp.printfc.constData(), MPS_TO_MPH(wpt->speed_value()));
}
break;
case XcsvStyle::XT_PATH_SPEED_KNOTS:
- if (WAYPT_HAS(wpt, speed)) {
- buff = QString::asprintf(fmp.printfc.constData(), MPS_TO_KNOTS(wpt->speed));
+ if (wpt->speed_has_value()) {
+ buff = QString::asprintf(fmp.printfc.constData(), MPS_TO_KNOTS(wpt->speed_value()));
}
break;
case XcsvStyle::XT_PATH_COURSE:
- if (WAYPT_HAS(wpt, course)) {
- buff = QString::asprintf(fmp.printfc.constData(), wpt->course);
+ if (wpt->course_has_value()) {
+ buff = QString::asprintf(fmp.printfc.constData(), wpt->course_value());
}
break;
}
break;
case XcsvStyle::XT_TEMPERATURE:
- if (WAYPT_HAS(wpt, temperature)) {
- buff = QString::asprintf(fmp.printfc.constData(), wpt->temperature);
+ if (wpt->temperature_has_value()) {
+ buff = QString::asprintf(fmp.printfc.constData(), wpt->temperature_value());
}
break;
case XcsvStyle::XT_TEMPERATURE_F:
- if (WAYPT_HAS(wpt, temperature)) {
- buff = QString::asprintf(fmp.printfc.constData(), CELSIUS_TO_FAHRENHEIT(wpt->temperature));
+ if (wpt->temperature_has_value()) {
+ buff = QString::asprintf(fmp.printfc.constData(), CELSIUS_TO_FAHRENHEIT(wpt->temperature_value()));
}
break;
/* TIME CONVERSIONS**************************************************/